package com.pengtu.service.trial;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.pengtu.dao.Page;
import com.pengtu.dao.QueryFilter;
import com.pengtu.dao.trial.OrderDao;
import com.pengtu.dao.trial.QuestionDao;
import com.pengtu.entity.trial.Order;
import com.pengtu.entity.trial.Question;

@Component
@Transactional
public class TrialManager {

	private OrderDao orderDao;
	private QuestionDao questionDao;

	// 操作Order
	public void saveOrder(Order order) {
		orderDao.save(order);
	}

	public void deleteOrder(String id) {
		orderDao.delete(id);
	}

	@Transactional(readOnly = true)
	public Order findByOrder(String propertyName, String value) {
		return orderDao.findUniqueBy(propertyName, value);
	}
	@Transactional(readOnly = true)
	public List<Order> findByListOrder(QueryFilter queryFilter) {
		return orderDao.find(queryFilter);
	}

	// 操作Question

	public void saveQuestion(Question question) {
		questionDao.save(question);
	}

	public void deleteQuestion(Question id) {
		questionDao.delete(id);
	}

	@Transactional(readOnly = true)
	public Question findByQuestion(String propertyName, String value) {
		return questionDao.findUniqueBy(propertyName, value);
	}
	@Transactional(readOnly = true)
	public List<Question> findByListQuestion(QueryFilter queryFilter) {
		return questionDao.find(queryFilter);
	}

	@Autowired
	public void setOrderDao(OrderDao orderDao) {
		this.orderDao = orderDao;
	}

	@Autowired
	public void setQuestionDao(QuestionDao questionDao) {
		this.questionDao = questionDao;
	}

	public void deleteOrderEntity(String id) {
		orderDao.deleteOrderEntity(id);
	}

	public Page<Order> findByOrderPage(Page<Order> page, QueryFilter filters) {
		return orderDao.findPage(page, filters);
	}
	
}
